package com.alibaba.csp.sentinel.dashboard.rule.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity;
import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider;
import com.alibaba.csp.sentinel.dashboard.rule.util.SentinelRuleUtil;

/**
 * 获取熔断规则
 * 
 * @author liu
 * @date 2021-09-08
 */
@Component("degradeRuleRedisProvider")
public class CustomDegradeRuleRedisProvider implements DynamicRuleProvider<List<DegradeRuleEntity>> {

    @Override
    public List<DegradeRuleEntity> getRules(String appName) throws Exception {
        return SentinelRuleUtil.getRules(RuleConsts.RULE_DEGRADE, appName, DegradeRuleEntity.class);
    }

}